<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org/">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>范闲商城-登录</title>
	<link rel="stylesheet" type="text/css" th:href="@{/static/css/reset.css}">
	<link rel="stylesheet" type="text/css" th:href="@{/static/css/main.css}">
	<link rel="stylesheet" th:href="@{/static/layui/css/layui.css}">
	<script th:src="@{/static/jquery-2.1.4.js}" type="text/javascript" charset="utf-8"></script>
	<script th:src="@{/static/layui/layui.js}" type="text/javascript" charset="utf-8"></script>
	<script th:src="@{/static/mylayer.js}" type="text/javascript" charset="utf-8"></script>
	<style>
		body {
			background: url(../static/pic/background.jpg) no-repeat center;
			background-size: cover;
		}
		.title-box{
			height: 40px;
			background: url(../static/pic/userlogin.png) no-repeat center;
			background-size: 100%;
		}
		.logo img {
			position: absolute; /* 将图片设置为绝对定位 */
			left: 50px; /* 将图片向右偏移200px */
			top: 0; /* 将图片置于父元素的顶部 */
		}
	</style>
</head>
<body>
<div class="logo">
	<img src="../../static/pic/xx-logo.png" alt="">
</div>

<div>
	<div class="login_form_wrap clearfix">
		<div class="login_form fr">
			<div class="form_input">
				<div class="title-box"></div><br>
				<form class="layui-form" action="/user?method=login" method="post">
					<div class="demo-login-container">
						<div class="layui-form-item">
							<div class="layui-input-wrap">
								<div class="layui-input-prefix">
									<i class="layui-icon layui-icon-username"></i>
								</div>
								<input type="text" name="account" value="" lay-verify="required" placeholder="账   号" lay-reqtext="请填写用户名" autocomplete="off" class="layui-input" lay-affix="clear">
							</div>
						</div>
						<div class="layui-form-item">
							<div class="layui-input-wrap">
								<div class="layui-input-prefix">
									<i class="layui-icon layui-icon-password"></i>
								</div>
								<input type="password" name="password" value="" lay-verify="required" placeholder="密   码" lay-reqtext="请填写密码" autocomplete="off" class="layui-input" lay-affix="eye">
							</div>
						</div>
						<div class="layui-form-item">
							<div class="layui-row">
								<div class="layui-col-xs7">
									<div class="layui-input-wrap">
										<div class="layui-input-prefix">
											<i class="layui-icon layui-icon-vercode"></i>
										</div>
										<input type="text" name="code" value="" lay-verify="required" placeholder="验证码" lay-reqtext="请填写验证码" autocomplete="off" class="layui-input" lay-affix="clear">
									</div>
								</div>
								<div class="layui-col-xs5">
									<div style="margin-left: 10px;">
										<img src="/verifyCode" onclick="this.src='/verifyCode?t='+ new Date().getTime();" width="120px" height="38px">
									</div>
								</div>
							</div>
						</div>
						<div class="layui-form-item">
							<input type="checkbox" name="autoLogin" lay-skin="primary" title="记住密码">
							<a href="/forget.jsp" style="float: right; margin-top: 7px;">忘记密码？</a>
						</div>
						<div class="layui-form-item">
							<button class="layui-btn layui-btn-fluid" lay-submit lay-filter="login">登录</button>
						</div>
						<div class="layui-form-item demo-login-other centered-container">
							<label>社交账号登录</label>
							<span style="padding: 0 21px 0 6px;">
									<a href="javascript:;"><i class="layui-icon layui-icon-login-qq" style="color: #3492ed;"></i></a>
									<a href="javascript:;"><i class="layui-icon layui-icon-login-wechat" style="color: #4daf29;"></i></a>
									<a href="javascript:;"><i class="layui-icon layui-icon-login-weibo" style="color: #cf1900;"></i></a>
								</span>
							或 <a href="/page/register">注册帐号</a>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>
<script>
	/*var queryString = window.location.search;
	var urlParams = new URLSearchParams(queryString);
	var redirect = urlParams.get("redirect");
	var categoryId = urlParams.get("categoryId");
	var productId = urlParams.get("productId");
	var parentId = urlParams.get("parentId");
	console.log(redirect);
	if (redirect == null || redirect === "") {
		redirects = '/';
	} else {
		redirects = redirect;
		if (parentId == null || parentId === "") {
			redirects = redirects;
		} else {
			redirects = redirects + '&' + 'parentId=' + parentId;
		}
		if (categoryId == null || categoryId === "") {
			redirects = redirects;
		} else {
			redirects = redirects + '&' + 'categoryId=' + categoryId;
		}
	}
	// if (redirect != null || redirect != "" && productId != null || productId != "") {
	// 	redirects = redirects + '&' + productId;
	// }

	console.log(redirects);*/
	layui.use(function(){
		var form = layui.form;

		var queryString = window.location.search;
		var urlParams = new URLSearchParams(queryString);
		var returnUri = urlParams.get("returnUri");
		console.log(returnUri);
		/*if (returnUri == null || returnUri === "") {
			returnUris = '/';
		} else {
			returnUris = returnUri;
			if (parentId == null || parentId === "") {
				returnUris = returnUris;
			} else {
				returnUris = returnUris + '&' + 'parentId=' + parentId;
			}
			if (categoryId == null || categoryId === "") {
				returnUris = returnUris;
			} else {
				returnUris = returnUris + '&' + 'categoryId=' + categoryId;
			}
		}*/
		// if (redirect != null || redirect != "" && productId != null || productId != "") {
		// 	redirects = redirects + '&' + productId;
		// }

		// 绑定提交事件
		form.on('submit(login)', function (data) {
			var field = data.field; // 获取表单字段值
			console.log(data);
			$.post(
					'/user/login',
					field,
					function (result) {
						if (result.code == 0) {
							if (returnUri == null || returnUri === "") {
								mylayer.okUrl(result.msg,'/');
							} else {
								mylayer.okUrl(result.msg,returnUri);
							}
						} else {
							mylayer.errorMsg(result.msg);
						}
					},
					'json'
			);
			return false; // 阻止默认 form 跳转
		});
		// 提交事件
		/*form.on('submit(login)', function(data){
			var field = data.field; // 获取表单字段值

			$.post(
					'/user/login',
					field,
					function (result) {
						console.log(result);
						if (result.code == 0) {
							if (redirects == null || redirects === "") {
								mylayer.okUrl(result.msg,'/');
							} else {
								mylayer.okUrl(result.msg,''+redirects+'');
							}

						} else {
							mylayer.errorMsg(result.msg);
						}
					},
					'json'
			);
			return false; // 阻止默认 form 跳转
		});*/
	});
</script>


	<div class="footer no-mp">
		<div class="foot_link">
			<a href="#">关于我们</a>
			<span>|</span>
			<a href="#">联系我们</a>
			<span>|</span>
			<a href="#">招聘人才</a>
			<span>|</span>
			<a href="#">友情链接</a>		
		</div>
		<p>CopyRight © 2024 北京鑫鑫科技有限公司 All Rights Reserved</p>
		<p>电话：010-8888888    京ICP备88888888号</p>
	</div>
	
</body>
</html>